/**
 * Copyright 2014 wasu.com
 *
 *
 * Create on 2015年4月2日 下午5:20:50
 */
package xj.toolkit.handler;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.common.base.Preconditions;

/**
 * 处理通知事件，是不需要有返回结果的。
 * 
 * @author <a href="mailto:caoxiaojian@wasu.cn">xiaojiancao</a>
 *
 */
public abstract class AbstractNotifyHandler<Q extends AbstractNotify> extends
		AbstractReqHandler<AbstractNotify> {

	private static final Logger logger = LoggerFactory
			.getLogger(AbstractNotifyHandler.class);

	/**
	 * @see com.wasu.upm.commons.handler.ReqHandler#doReq(com.wasu.upm.commons.AbstractUPMRequest)
	 */
	protected abstract void doReq1(Q notifiy);

	/**
	 * @see com.wasu.upm.commons.handler.ReqHander#doReq(com.wasu.upm.commons.
	 *      AbstractUPMRequest)
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void doReq0(AbstractNotify request) {
		Preconditions.checkArgument(request != null
				&& request.getIdentification() != null);

		logger.debug("Start process request[{}].", request);

		try {
			doReq1((Q) request);
		} catch (Exception exception) {
			logger.error("Prorcess reqest[" + request + "] fail.", exception);

		}

	}
}
